<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>promise的all方法</title>
  </head>
  <body>
    <script>
      // 如果一个需求需要发送两次请求才可以完成，就需要用到Promise.all
      Promise.all([
        new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve({ name: "LMX", age: 18 });
          }, 1000);
        }),
        new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve({ name: "LLL", age: 20 });
          }, 1000);
        }),
      ]).then((res) => {
        console.log(res);
      });
    </script>
  </body>
</html>
